import QtQuick 2.0
import QtWebEngine 1.5
import QtWebChannel 1.0
import QtQuick.Controls 2.2

Item{
    clip:true

    WebChannel{
        id:htmlchannel
        objectName: "objwebchannel"
        registeredObjects:webchannelobject
    }
    QtObject{
        id:webchannelobject
        objectName: "objobject"
        WebChannel.id: "content"
        signal createmarker(var lat, var lng, string msg)
        signal clearmarker
        function buildingmap(){
            console.log("building map")
        }
    }

    WebEngineView {
        url:"file://"+RootController.getMcConfigInfo("[MCUIInfo]" , "baidumaphtml")
        width: parent.width
        height: parent.height
        y:-7
        x:-7
        webChannel: htmlchannel
        onLoadProgressChanged: {
            if(loadProgress === 100){
                createmcmarker.running = true
            }
        }
    }


    property string mcinfo: ""

    Timer{
        id:createmcmarker
        interval: 1000
        triggeredOnStart: false
        running: false
        repeat: false
        onTriggered: {
            console.log("Offline Map Over")
            mcinfo = "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>"+RootController.getMcConfigInfo("[MCUIInfo]" , "name")+"</h4>" +
                    "<img style='float:right;margin:4px' id='imgDemo' src='images/MC.jpg' width='139' height='104' title='天安门'/>" +
                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>"+RootController.getMcConfigInfo("[MCUIInfo]" , "descr")+"</p>" +
                    "</div>"
            webchannelobject.createmarker(RootController.getMcConfigInfo("[MCUIInfo]" , "lat"),
                                          RootController.getMcConfigInfo("[MCUIInfo]" , "lng"),
                                          mcinfo)
        }
    }


}
